﻿using System;
using System.Collections.Generic;
using System.Diagnostics.Contracts;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace YasharEl.Infrastructure.WorkflowModel
{
    [ContractClass(typeof(WorkflowCompletionHandlerContract))]
    public interface IWorkflowCompletionHandler
    {
        void OnFaulted(Guid workflowInstanceId, Exception fault);//, IDictionary<string, object> promotedValues);

        void OnSuccessfulCompleted(Guid workflowInstanceId);//, IDictionary<string, object> promotedValues);

        void OnCancelled(Guid workflowInstanceId);//, IDictionary<string, object> promotedValues);

        void OnAborted(Guid workflowInstanceId, Exception fault);//, IDictionary<string, object> promotedValues);
    }

    [ContractClassFor(typeof(IWorkflowCompletionHandler))]
    internal abstract class WorkflowCompletionHandlerContract : IWorkflowCompletionHandler
    {
        public void OnFaulted(Guid workflowInstanceId, Exception fault)//, IDictionary<string, object> promotedValues)
        {
            Contract.Requires<ArgumentNullException>(workflowInstanceId != Guid.Empty, "workflowInstanceId must be valid Guid.");
            Contract.Requires<ArgumentNullException>(fault != null, "fault could not be null.");
        }

        public void OnSuccessfulCompleted(Guid workflowInstanceId)//, IDictionary<string, object> promotedValues)
        {
            Contract.Requires<ArgumentNullException>(workflowInstanceId != Guid.Empty, "workflowInstanceId must be valid Guid.");
        }

        public void OnCancelled(Guid workflowInstanceId)//, IDictionary<string, object> promotedValues)
        {
            Contract.Requires<ArgumentNullException>(workflowInstanceId != Guid.Empty, "workflowInstanceId must be valid Guid.");
        }

        public void OnAborted(Guid workflowInstanceId, Exception fault)//, IDictionary<string, object> promotedValues)
        {
            Contract.Requires<ArgumentNullException>(workflowInstanceId != Guid.Empty, "workflowInstanceId must be valid Guid.");
            Contract.Requires<ArgumentNullException>(fault != null, "fault could not be null.");
        }
    }
}
